
describe("PublicLoginController in SG", function() {
    var publicLoginController = null;

    beforeEach(function() {
        publicLoginController = App.PublicLoginController.create();
    });

    describe("callback method test", function() {

        it("callback method - success", function() {

            var objE = {};

            spyOn(publicLoginController, 'hideLoading');
            spyOn(publicLoginController, '_clearInput');
            spyOn(App, 'startSessionTimer');
            spyOn(publicLoginController, 'hasError').andReturn(false);
            spyOn(publicLoginController, 'transitionTo');

            publicLoginController.callback(objE);

            expect(publicLoginController.hideLoading).toHaveBeenCalled();
            expect(publicLoginController._clearInput).toHaveBeenCalled();
            expect(publicLoginController.hasError).toHaveBeenCalledWith(objE);
            expect(App.startSessionTimer).toHaveBeenCalled();
            expect(publicLoginController.transitionTo).toHaveBeenCalledWith('restricted');
        });
        
        it("callback method - error", function() {

            var objE = {
                errorCode: 'code',
                errorMessage: 'message'
            };

            spyOn(publicLoginController, 'hideLoading');
            spyOn(publicLoginController, '_clearInput');
            spyOn(App, 'startSessionTimer');
            spyOn(publicLoginController, 'hasError').andReturn(true);
            spyOn(publicLoginController, 'transitionTo');

            publicLoginController.callback(objE);

            expect(publicLoginController.hideLoading).toHaveBeenCalled();
            expect(publicLoginController._clearInput).toHaveBeenCalled();
            expect(publicLoginController.hasError).toHaveBeenCalledWith(objE);
            expect(App.startSessionTimer).not.toHaveBeenCalled();
            expect(publicLoginController.transitionTo).not.toHaveBeenCalledWith('restricted');
        });
    });
});